﻿using System;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Windows.Documents;

namespace Elifart.Library
{
    [Serializable]
    public class AthleteCollection : BindingList<Athlete>, ICloneable
    {
        #region Constructor

        public AthleteCollection()
        {
        }

        #endregion

        #region Attributes and Properties

        public Athlete this[string guid]
        {
            get
            {
                foreach (Athlete athlete in this)
                    if (string.Compare(athlete.GUID, guid) == 0)
                        return athlete;

                return null;
            }
        }

        #endregion

        #region ICloneable Members

        public object Clone()
        {
            AthleteCollection cloned = new AthleteCollection();

            foreach (Athlete athlete in this)
                cloned.Add(athlete.Clone() as Athlete);

            return cloned;
        }

        #endregion
    }
}
